import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:[],
    lists:[]
  },
  mutations: {
    // 添加
    addPut(state,obj){
      state.list.push(obj)
      
    },
    addChe(state,index){
      if(state.list[index].checked == true){
        state.list[index].isFlag = 'b'
      }else{
        state.list[index].isFlag = 'a'
      }
    },
    addQx(state,index){
      state.list[index].isFlag = 'c'
    },
    // 删除
    addDel(state,index){
      state.list.splice(index,1)
    },
    addisEd(state,index){
      state.list[index].isEd = !state.list[index].isEd
    },
    // 留言板==========================================
    addLis(state,obj){
      state.lists.unshift(obj)
    },
    del(state,index){
      state.lists.splice(index,1)
    },
    yd(state,index){
      if(state.lists[index].checked == true){
        state.lists[index].activeName = 2
      }else{
        state.lists[index].activeName = 1
      }
    },
    hs(state,index){
      state.lists[index].activeName = 3
    },
  },
  actions: {

  },
  plugins:[persistedState()]
})
